// http://deepliquid.com/content/Jcrop_Download.html
public class ImageTest {
 
	private static final int IMG_WIDTH = 100;
	private static final int IMG_HEIGHT = 100;
 
	public static void main(String [] args){
		try{
	 
			BufferedImage originalImage = ImageIO.read(new File("c:\\image\\mkyong.jpg"));
			int type = originalImage.getType() == 0? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
	 
			BufferedImage resizeImageJpg = resizeImage(originalImage, type);
			ImageIO.write(resizeImageJpg, "jpg", new File("c:\\image\\mkyong_jpg.jpg")); 
	 
			BufferedImage resizeImagePng = resizeImage(originalImage, type);
			ImageIO.write(resizeImagePng, "png", new File("c:\\image\\mkyong_png.jpg")); 
	 
		}catch(IOException e){
			System.out.println(e.getMessage());
		}
    }
 
    private static BufferedImage resizeImage(BufferedImage originalImage, int type){
		BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);
		Graphics2D g = resizedImage.createGraphics();
		g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
		g.dispose();
	 
		return resizedImage;
	    }
    }
    
     private BufferedImage cropImage(BufferedImage src, Rectangle rect) {
      BufferedImage dest = src.getSubimage(0, 0, rect.width, rect.height);
      return dest; 
   }